Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stricter typing for SegmentedButtons component #4532

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jboteros
Copy link

@jboteros jboteros commented Oct 23, 2024

Related to #4528

Add stricter typing for onValueChange in SegmentedButtons component to support union types in TypeScript projects.

  • Modify src/components/SegmentedButtons/SegmentedButtons.tsx to accept a generic type parameter for the value and onValueChange props.
    • Update ConditionalValue type to use the generic type parameter.
    • Update Props type to use the generic type parameter.
  • Update example files to demonstrate the usage of the stricter typing:
    • example/src/Examples/SegmentedButtons/SegmentedButtonDefault.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonWithSelectedCheck.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonWithDensity.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonMultiselect.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonMultiselectIcons.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonCustomColorCheck.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonDisabled.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonMultiselectRealCase.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonOnlyIcons.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonOnlyIconsWithCheck.tsx
    • example/src/Examples/SegmentedButtons/SegmentedButtonRealCase.tsx
    • example/src/Examples/SegmentedButtonsExample.tsx
    • example/src/Examples/ToggleButtonExample.tsx

For more details, open the Copilot Workspace session.

Related to callstack#4528

Add stricter typing for `onValueChange` in `SegmentedButtons` component to support union types in TypeScript projects.

* Modify `src/components/SegmentedButtons/SegmentedButtons.tsx` to accept a generic type parameter for the `value` and `onValueChange` props.
  * Update `ConditionalValue` type to use the generic type parameter.
  * Update `Props` type to use the generic type parameter.
* Update example files to demonstrate the usage of the stricter typing:
  * `example/src/Examples/SegmentedButtons/SegmentedButtonDefault.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonWithSelectedCheck.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonWithDensity.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonMultiselect.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonMultiselectIcons.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonCustomColorCheck.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonDisabled.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonMultiselectRealCase.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonOnlyIcons.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonOnlyIconsWithCheck.tsx`
  * `example/src/Examples/SegmentedButtons/SegmentedButtonRealCase.tsx`
  * `example/src/Examples/SegmentedButtonsExample.tsx`
  * `example/src/Examples/ToggleButtonExample.tsx`

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/callstack/react-native-paper/issues/4528?shareId=XXXX-XXXX-XXXX-XXXX).
@callstack-bot
Copy link

callstack-bot commented Oct 23, 2024

Hey @jboteros, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

…cter typing

* Remove unnecessary filter function in `filteredData` calculation
* Fix ESLint error by updating code formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants